package com.eleven.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eleven.pojo.Msg;
import com.eleven.pojo.QuestionAll;
import com.eleven.pojo.QuestionOther;
import com.eleven.service.QuestionAllService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
public class QuestionAllController {
	@Autowired
	QuestionAllService questionAllService;

	public QuestionAllService getQuestionAllService() {
		return questionAllService;
	}

	public void setQuestionAllService(QuestionAllService questionAllService) {
		this.questionAllService = questionAllService;
	}
	/**
	 * 查看全部问题总支
	 * question_index
	 */

	@RequestMapping(value = "/getAllQuestionAll", method = RequestMethod.GET)
	@ResponseBody
	public Msg getLetters(@RequestParam(value = "pn", defaultValue = "1") Integer pn) {
		PageHelper.startPage(pn, 20);//传入页码和每页显示的数量
		List<QuestionAll> questionAll = questionAllService.getAllQuestionAll();

		PageInfo pageInfo = new PageInfo(questionAll, 1);//1是连续显示1页的内容
		if(questionAll.size() > 0) {
			return Msg.success().add("pageInfo", pageInfo);
		}else {
			return Msg.fail().add("message", "该分支下暂无问题");
		}
	}
}
